import { defineStore } from 'pinia';
import request from '@/utils/request'
import {getChatConfig} from "@/api/chat.js"
export default defineStore('configStore',{
	state: () => {
		return {
			webrtc: {}
		}
	},
	actions: {
		setConfig(config) {
			this.webrtc = config.webrtc;
		},
		clear() {
			this.webrtc = {};
		},
		loadConfig() {
			return new Promise((resolve, reject) => {
				getChatConfig().then((config) => {
				
					this.setConfig(config.data);
					resolve();
				}).catch((res) => {
					reject(res);
				});
			})
		}
	}
})
